import pandas as pd
# from langchain_experimental.tools.python.tool import PythonREPLTool

# 创建Python代码解释器，目前使用PythonAstREPLTool报错
from langchain_experimental.tools import PythonAstREPLTool # 从LangChain依赖库引入Python代码解释器
df = pd.read_csv("testData.csv")
# ---pd读取csv格式的文件内容---
# meanData = df['GDP_Billion_USD'].mean()
# print(meanData)

tool = PythonAstREPLTool(locals={"df": df})
# tool = PythonREPLTool(locals={"df": df})
res = tool.invoke("df['GDP_Billion_USD'].mean()")
print(res)



